package com.company;

public class Monster{
    int curLife;
    int maxLife;
    String type;
    boolean isLive = true;
    int attack;
    int defend;
    int agile;
    int hideRate;
    int treasure;
    public Monster(int mt){
        switch(mt){
            case 1: type = "小丑";maxLife = 80; curLife = 80;   attack = 25;defend = 15;    agile = 30;hideRate = 20; treasure = 0;   break;
            case 2: type = "杰森";maxLife = 200; curLife = 60;   attack = 28;defend = 30;    agile = 0;hideRate = 0; treasure = 1;   break;
            case 3: type = "弗莱迪";maxLife = 40; curLife = 40;   attack = 10;defend = 5;     agile = 100;hideRate = 90; treasure = 1;   break;
            case 4: type = "冰雅蝶雪恋"; maxLife = 99999; curLife = 99999; attack = 0; defend = 1; agile = 9;hideRate = 0; treasure = 10; break;
            case 5: type = "陷阱"; maxLife = 99999; curLife = 99999; attack = 99999; defend = 99999; agile = 99999;hideRate = 100; treasure = 100; break;
        }
    }

    public void injured(Hunter hunter){
        if(GameUtil.hidden(this.agile,this.hideRate)){
            System.out.println(type+"发出了奇怪的声音，但是"+hunter.name+"不可思议的理解了"+type+"的意思，它再说：‘正视我，闸总！’");
            show();
            kill(hunter);
            return;
        }
        System.out.println(type+"感到自身AC值奇妙的降低了");
        int lostLife = GameUtil.calLostLife(hunter.attack, this.defend);
        curLife-=lostLife;
        if(curLife<0){
            curLife=0;
            died(hunter);
            return;
        }
        show();
        kill(hunter);
    }
    public void died(Hunter hunter){
        this.isLive = false;
        System.out.println(type+"内脏变成了外脏");
        hunter.treasure=hunter.treasure+treasure;
        System.out.println("贪婪的猎人，你现在有"+hunter.treasure+"件珍宝了");
        hunter.expAdd(this);
    }
    public void kill(Hunter hunter){
        if(isLive){
            System.out.println(type+"令"+hunter.name+"感到流失");
            hunter.injured(this);
        }else{
            System.out.println(type+"内脏变成了外脏");
        }
    }
    public void show(){
        System.out.println(type+"  "+"生命值："+curLife+"  ");
    }
}
